import { defineStore } from "pinia";
import http from "@/api/http";
// useStore 可以是 useUser、useCart 之类的任何东西
// 第一个参数是应用程序中 store 的唯一 id
export const useStore = defineStore("main", {
  state: () => {
    return {
      // 搜索
      search: "",
      cartCount: 0,
    };
  },
  actions: {
    onSearch(data) {
      this.search = data;
    },
    getCartTotal() {
      const url = "/buyerShoppingCart/getAmount";
      http.get({ url }).then((res) => {
        this.cartCount = res
      });
    },
  },
});
